



//https://www.ozon.ru/api/entrypoint-api.bx/page/json/v2?url=/product/1185794392/?layout_container=pdpPage2column&layout_page_index=2
function getQueryString(name) {
    let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    let r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return r[2];
    }
    return 0;
 }
 console.log("shein detail by api")


$(document).ready(function() {
    getStockByFetch();
});
function  getStockByFetch(msg){

    /*if(location.href.includes("/risk/action/limit")){
        setTimeout(function() {
            window.close();
        }, 5000);
        return;
    }else{
        setTimeout(function() {
            window.close();
        }, 20000);
    }*/
    var bodyContent = $('body').text();
    console.log(bodyContent)

    var jsonObject = JSON.parse(bodyContent);

    if(jsonObject['code']=="200301"){
        var type = "sheindetaildel";
        var data={}
        data.id = getQueryString("bid");
        console.log(data);
        chrome.runtime.sendMessage({ data: {type,data }, close: false })
        setTimeout(function() {
            window.close();
        }, 10000);
    }else if(jsonObject['info']){
        getDataDetailPageV2(jsonObject,getQueryString("bid"));
        /*setTimeout(function() {
            window.close();
        }, 10000);*/
    }


    console.log(stock_map);

}

